<template>

  <el-container>
    <!-- 左侧样式导航栏区域-->
  <el-aside  :style="{width:isCollapse?'65px': '200px'}">
    <el-menu
      default-active="2"
      class="el-menu-vertical-demo"

      background-color="#323745"
      text-color="#fff"
      active-text-color="#ffd04b"
      :collapse="isCollapse"
      :collapse-transition="false"
      :router='true'
      >
      <el-menu-item index="/welcome">
          <i class="el-icon-location"></i>
        <span slot="title">首页</span>
      </el-menu-item>
      <el-submenu index="2">
        <template slot="title">
           <!-- <i class="el-icon-menu"></i> -->
          <i class="el-icon-menu"></i>
          <span>内容管理</span>
        </template>
        <el-menu-item-group>
          <el-menu-item index="2-1">发布文章</el-menu-item>
          <el-menu-item index="/article">文章列表</el-menu-item>
          <el-menu-item index="2-3">评论列表</el-menu-item>
          <el-menu-item index="2-4">素材管理</el-menu-item>
        </el-menu-item-group>
      </el-submenu>
      <!-- <el-menu-item index="3">
          <i class="el-icon-menu"></i>
         <i class="el-icon-menu"></i>
        <span slot="title">导航二</span>
      </el-menu-item> -->
      <el-menu-item index="3" >
        <i class="el-icon-document"></i>
        <span slot="title">粉丝管理</span>
      </el-menu-item>
      <el-menu-item index="4">
        <i class="el-icon-setting"></i>
        <span slot="title">账户信息</span>
      </el-menu-item>
    </el-menu>

  </el-aside>
  <!-- 头部样式 -->
  <el-container>
    <el-header>
      <!-- to头部左侧盒子 -->
      <div id="lt" @click="isCollapse=!isCollapse">
        <i :class="isCollapse?'el-icon-s-fold':'el-icon-s-unfold'"  style="margin: 0 5px"></i>
        <span>江苏传智播客教育科技股份有限公司</span>
      </div>
       <div id="rt">
          <!-- <el-input type="text" placeholder="请输入搜索文章的内容" style="width:240px;">
            <i class="el-icon-search" slot="prefix"></i>
          </el-input> -->
           <el-input
    placeholder="请输入内容"
    prefix-icon="el-icon-search"
     style="width:240px;">
  </el-input>
          <span style="margin:0 25px;">消息</span>
          <el-dropdown trigger="click">
            <span class="el-dropdown-link">
              <img :src="phone" alt width="40" height="40" style="margin-right:10px;">
              {{name}}
              <i class="el-icon-arrow-down el-icon--right"></i>
            </span>
            <el-dropdown-menu slot="dropdown">
              <el-dropdown-item>个人信息</el-dropdown-item>
              <el-dropdown-item>github地址</el-dropdown-item>
              <el-dropdown-item @click.native="logout()">退出</el-dropdown-item>
            </el-dropdown-menu>
          </el-dropdown>
        </div>

    </el-header>
    <el-main>
      <router-view></router-view>

    </el-main>
  </el-container>
</el-container>

</template>

<script>
export default {
  created () {

  },
  data () {
    return {
      // 控制头部左侧盒子图标切换
      isCollapse: false

    }
  },
  // 计算属性
  computed: {
    name () {
      return JSON.parse(window.sessionStorage.getItem('token')).name
    },
    phone () {
      return JSON.parse(window.sessionStorage.getItem('token')).photo
    }
  },
  methods: {
    // 退出函数功能实现
    logout () {
      this.$confirm('确认要退出系统么？', '退出', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        // 清除掉session
        window.sessionStorage.clear()
        // 重定向到登录页面
        this.$router.push('/login')
      }).catch(() => {})
    }
  }
}
</script>

<style lang="less" scoped>

.el-container {
  height:100%;
  .el-aside {
    background-color: rgb(50, 55, 69);
  }
   .el-header {
    display: flex;
    justify-content: space-between;
    padding: 0 9px 0 10px;
    min-width: 800px;
    #lt {
      height: 100%;
      width: 40%;
      font-size: 20px;
      display: flex;
      align-items: center;
    }
    #rt {
      height: 100%;
      width: 50%;
      display: flex;
      justify-content: flex-end;
      align-items: center;

      .el-dropdown-link {
        display: flex;
        align-items: center;
        height: 100%;
      }
    }
  }
  .el-main{
    background-color: #f2f3f5;
  }
}

</style>
